home *** CD-ROM | disk | FTP | other *** search
- /*
- PostJet
- */
-
- /*
- Getprefs
- */
- if open(p,'env:postjet.prefs','R') then do
- guifile=readln(p)
- guifile=guifile||'/postjet.gui'
- printer=readln(p)
- pagesize=readln(p)
- initfile=readln(p)
- useropts=readln(p)
- call close(p)
- end
- else do
- say "Cannot open preference file."
- exit
- end
-
- select
- when printer='deskjet' then baseopts='-j0'
- when printer='laserjet' then baseopts='-j2'
- otherwise do
- say 'Config file error - line 1 : printer name'
- exit
- end
- end
-
- select
- when pagesize='letter' then baseopts=baseopts||' -s0'
- when pagesize='legal' then baseopts=baseopts||' -s1'
- when pagesize='a4' then baseopts=baseopts||' -s3'
- otherwise do
- say 'Config file error - line 2 : paper type'
- exit
- end
- end
-
- /*
- Open support library
- */
- if ~show("L","rexxsupport.library") then
- if ~addlib('rexxsupport.library',0,-30,0) then do
- say "Cannot open rexxsupport.library"
- exit
- end
-
- /*
- Launch varexx server
- */
- if ~show('p','VAREXX') then do
- address command 'run >nil: varexx'
- waitforport VAREXX
- end
-
- /*
- VAREXX default port
- */
- address VAREXX
-
- /*
- Create message port for the window
- */
- call OPENPORT('POSTJETWIN')
-
- /*
- Load gui
- */
- options results
- 'load' guifile 'POSTJETWIN'
-
- /*
- Get window port
- */
- port=result
- address value port
-
- /*
- Show window
- */
- show
-
- /*
- Prepare variables
- */
- filename='NONE'
- pageno='0'
-
- /*
- Message loop
- */
- do until message = CLOSEWINDOW
-
- /*
- Wait for a packet
- */
- call WAITPKT("POSTJETWIN")
- packet=GETPKT("POSTJETWIN")
-
- /*
- If packet exists get the message
- */
- if packet ~= '00000000'x then do
- message=GETARG(packet)
-
- /*
- Make proper action
- */
- select
-
- when message=PRINTODDPAGES then do
- if filename~='NONE' then do
- 'busy set'
- pn=pagenumbers()
- do i=1 to pn by 2
- say 'Printing page' i 'of file' filename
- opts=baseopts||' -b'||i||'e'||i||' '||' '||initfile||' '||filename
- address command 'postlj >nil: '||opts
- end
- 'busy'
- end
- end
-
- when message=PRINTEVENPAGES then do
- if filename~='NONE' then do
- 'busy set'
- pn=pagenumbers()
- do i=2 to pn by 2
- say 'Printing page' i 'of file' filename
- opts=baseopts||' -b'||i||'e'||i||' '||' '||initfile||' '||filename
- address command 'postlj >nil: '||opts
- end
- 'busy'
- end
- end
-
- when message=PRINTSINGLEPAGE then do
- if filename~='NONE' then do
- 'busy set'
- pn=pagenumbers()
- if ((pageno>0)&(pageno<=pn)) then do
- say 'Printing page' pageno 'of file' filename
- opts=baseopts||' -b'||pageno||'e'||pageno||' '||' '||initfile||' '||filename
- say 'postlj '||opts
- address command 'postlj >nil: '||opts
- end
- 'busy'
- end
- end
-
- when message=GETPOSTFILENAME then do
- address command 'requestfile >t:pjgfntf'
- open(t,"t:pjgfntf",'R')
- filename=strip(readln(t),'B','"')
- call close(t)
- address command 'delete >nil: t:pjgfntf'
- 'settext POSTFILENAME' filename
- end
-
- when word(message,1)=POSTFILENAME then filename=word(message,2)
-
- when word(message,1)=PAGENUMBER then pageno=word(message,2)
-
- otherwise if message~=CLOSEWINDOW then do
- say 'Internal error in main loop. Please mail these informations'
- say 'to the author:'
- say 'MAIN WIN LOOP - OTHERWISE - MESSAGE:' message
- exit
- end
-
- end
-
- end
-
- end
-
- /*
- Close window
- */
- 'hide unload'
-
- /*
- Close message port
- */
- call CLOSEPORT("POSTJETWIN")
-
- /*
- Close varexx server
- */
- address command 'vxc >nil:'
-
- /*
- Exit
- */
- exit
-
- pagenumbers:
-
- if ~open(t,filename,'R') then do
- return 0
- end
-
- close(t)
-
- address command 'search from '||filename||' search "%%Pages:" >ram:spnff'
-
- if ~open(t,"ram:spnff",'R') then do
- return 0
- end
-
- do forever
- riga=readln(t)
- riga=word(riga,3)
-
- w=verify(riga,"1234567890")
- do while w~==0
- riga=substr(riga,1,w-1)||substr(riga,w+1,length(riga)-w)
- w=verify(riga,"1234567890")
- end
-
- if riga~=="" then return riga
-
- if eof(t) then do
- close(t)
- return 0
- end
- end
-